package satir.record.factory;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.json.JSONObject;
import satir.framework.JSONIOPerformer.JSONIOPerformerJSONDecodeException;
import satir.framework.JSONIOPerformer.JSONIOPerformerReadException;
import satir.framework.refectoring.Factory;
import satir.record.GameRecord;
import satir.record.SavedEntity.JSONFileInvalidException;

/**
 * A factory for creating Profile object.
 * @version 3.0 April 2012
 * @author Creative Family
 */
public class GameRecordFactory implements Factory {

    /**
     * Creates the.
     * @param json
     *            the JSON
     * @return the object
     * @see Factory, LazyInitiator
     */
    @Override
    public Object create(final JSONObject json) {
        GameRecord gameRecord = null;
	try {
	    DateFormat dateFormat = new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss");
	    Date date = new Date();
	    String todayDate = dateFormat.format(date);
	    gameRecord = new GameRecord("gameRecord_" + todayDate + ".json",
		    "temp/");
	} catch (JSONIOPerformerReadException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	} catch (JSONIOPerformerJSONDecodeException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	} catch (JSONFileInvalidException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
	return gameRecord;
    }
}
